package com.sofwin;

import lombok.Data;

import java.io.Serializable;

/**
 * @packageName: com.sofwin
 * @user: andyliu
 * @date: 2022/12/30 16:07
 * @email 115176513@qq.com
 * @description: TODO
 */
@Data
public class ResponseEntity implements Serializable {

    private static final long serialVersionUID = 5635401903050772516L;
    // 响应状态码 200 600 700
    private Integer code;
    // 响应信息（提示信息）
    private String message;
    // 响应的数据
    private Object result;

    public ResponseEntity(){

    }
    public ResponseEntity(Integer code,String message,Object result){
        this.code = code;
        this.message = message;
        this.result = result;
    }

    // 操作成功的响应
    public static ResponseEntity success(Object result){
        return new ResponseEntity(200,null,result);
    }
    public static ResponseEntity success(String message,Object result){
        return new ResponseEntity(200,message,result);
    }
    public static ResponseEntity success(Integer code,String message,Object result){
        return new ResponseEntity(code,message,result);
    }
    public static ResponseEntity error(Object result){
        return new ResponseEntity(201,null,result);
    }
    public static ResponseEntity error(String message,Object result){
        return new ResponseEntity(201,message,result);
    }
    public static ResponseEntity error(Integer code,String message,Object result){
        return new ResponseEntity(code,message,result);
    }

}
